package cn.tedu.net.collection.seri;

import java.io.Serializable;
import java.util.Objects;

//本类用来封装学生类
    //本类如果想要完成序列化必须实现可序列化接口,否则会报错:NotSerializableException
    //serializable接口是一个空接口,里面一个方法都没有
    //作用:作为标志,标志这个类可以被序列化/反序列化
public class Student implements Serializable{
    private static final long serialVersionUID = 1197852836737903947L;
    //需要给每个序列化的文件分配唯一的序列地址
    private String name;
    private int age;
    private String gender;
    private String address;//地址

    public Student() {
    }

    public Student(String name, int age, String gender, String address) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name) && Objects.equals(gender, student.gender) && Objects.equals(address, student.address);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
}
